// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { devPlugin, getReplacer } from "./plugins/devPlugin";
import optimizer from "vite-plugin-optimizer";
import { buildPlugin } from "./plugins/buildPlugin";
import path from "path";

export default defineConfig({
  plugins: [optimizer(getReplacer()),devPlugin(), vue()],
  server: {
    host: '127.0.0.1', // 强制使用 IPv4
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
  build: {
    rollupOptions: {
        plugins: [buildPlugin()],
        output: {
          manualChunks: (id) => id.includes('node_modules') ? 'vendor' : undefined
        }
    },
    chunkSizeWarningLimit: 1000
  }
});